<template>
  <div class="transfer-amount">
     <el-dialog :visible.sync="showValue" :before-close="cancel" width="60%">
    <template slot="title">
      {{title}}
    </template>
    <el-form :model="form" ref="transferAmount" :rules="configsRule">
      <el-form-item>
         <el-row>
          <el-col :span="12">
            <div>向中心钱包转账限额</div>
            <el-form-item label="每日可转账次数" prop="inTimes"  :label-width="formLabelWidth">
              <el-col :span="16">
                <el-input placeholder="请输入次数" v-model.number="form.inTimes">
                  <template slot="append">次</template>
                </el-input>
              </el-col>
            </el-form-item>
            <el-form-item label="每次可转账金额"  :label-width="formLabelWidth">
            </el-form-item>
            <el-form-item label="最低" prop="inMin"  :label-width="formLabelWidth">
              <el-col :span="16">
                <el-input placeholder="请输入金额" v-model.number="form.inMin">
                  <template slot="append">元</template>
                </el-input>
              </el-col>
            </el-form-item>
            <el-form-item label="最高" prop="inMax"  :label-width="formLabelWidth">
              <el-col :span="16">
                <el-input placeholder="请输入金额" v-model.number="form.inMax">
                  <template slot="append">元</template>
                </el-input>
              </el-col>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <div>向游戏钱包转账限额</div>
            <el-form-item label="每日可转账次数" prop="outTimes"  :label-width="formLabelWidth">
              <el-col :span="16">
                <el-input placeholder="请输入次数" v-model.number="form.outTimes">
                  <template slot="append">次</template>
                </el-input>
              </el-col>
            </el-form-item>
            <el-form-item label="每次可转账金额"  :label-width="formLabelWidth">
            </el-form-item>
            <el-form-item label="最低" prop="outMin"  :label-width="formLabelWidth">
              <el-col :span="16">
                <el-input placeholder="请输入金额" v-model.number="form.outMin">
                  <template slot="append">元</template>
                </el-input>
              </el-col>
            </el-form-item>
            <el-form-item label="最高" prop="outMax"  :label-width="formLabelWidth">
              <el-col :span="16">
                <el-input placeholder="请输入金额" v-model.number="form.outMax">
                  <template slot="append">元</template>
                </el-input>
              </el-col>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form-item>        
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="cancel">取 消</el-button>
      <el-button type="primary" @click="doSave({action: 'saveForm', form: 'transferAmount'})" :loading="loading">申 请
      </el-button>
    </div>
  </el-dialog>
  </div>
</template>
<script>
import { form ,factory} from "@/build";
import {riskTransferAmountApi as saveApi } from "@/services/api/risk";
export default {
  name: "transfer-amount-dialog",
  props: ["showValue", "rowData", "userId"],
  mixins: [form ,factory,],
  data() {
    return {
      title: "开启转账",
      formLabelWidth: "140px",
      form: {
        inMin: undefined,
        inMax: undefined,
        inTimes: undefined,
        outMin: undefined,
        outMax: undefined,
        outTimes: undefined
      },
      configsRule: {
        inTimes: factory.getRule("times"),
        inMin: factory.getRule("money"),
        inMax: factory.getRule("money"),
        outTimes: factory.getRule("times"),
        outMin: factory.getRule("money"),
        outMax: factory.getRule("money")
      }
    };
  },
  methods: {
    cancel() {
      this.$emit("closeDialog");
    }
  },
  mounted(){
    this.bindSave(saveApi, 'saveForm', 'form', {
        beforeSend: data=>{         
          let userId=[];
          this.userId.map((item,index)=>{
            userId.push(item.userId)
          })
          return {...this.form,userId:userId.join(",")}
        },
        afterSuccess:data=>{
          this.cancel();
          this.$parent.getAll();
        }
      });

      if(this.rowData != undefined){
        const {inMin,inMax,inTimes,outMin,outMax,outTimes} =this.rowData;
        this.form={inMin,inMax,inTimes,outMin,outMax,outTimes}
      }
  }
};
</script>

